Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time scale ticks.reverse issue #5933

Merged
merged 1 commit into from
Jan 2, 2019
Merged

Conversation

nagix
Copy link
Contributor

@nagix nagix commented Dec 22, 2018

When ticks.reverse is set to true in a time scale, there are a few issues:

  1. Bars overlap each other.
  2. Offsets are not calculated correctly when offset is set to true
  3. The order of bars in a group is also reversed when barThickness is set to 'flex'
  4. A bar is not shown when barThickness is set to 'flex' and there is only a single data point

This PR fixes the issues above, and also improves the offset calculation when there is only one tick in a chart.

Master: https://jsfiddle.net/nagix/7kahbfcn/

screen shot 2018-12-23 at 12 02 23 am

This PR: https://jsfiddle.net/nagix/5ydbhwa7/

screen shot 2018-12-23 at 12 01 43 am

var scale = this.chart.scales.x;
expect(scale.getPixelForValue('2017')).toBeCloseToPixel(scale.left + scale.width);
expect(scale.getPixelForValue('2042')).toBeCloseToPixel(scale.left);
});

it ('should reverse the bars and add offsets if offset is true', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: bars when chart type is line.

@simonbrunel simonbrunel added this to the Version 2.8 milestone Jan 2, 2019
@simonbrunel simonbrunel merged commit 39b4d61 into chartjs:master Jan 2, 2019
@simonbrunel
Copy link
Member

Thanks @nagix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants